package com.xzg.erp.system.service.impl;

import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xzg.erp.common.Constants;
import com.xzg.erp.system.entity.SysOrganization;
import com.xzg.erp.system.entity.dto.OrgTreeDto;
import com.xzg.erp.system.mapper.SysOrganizationMapper;
import com.xzg.erp.system.service.ISysOrganizationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 组织表 服务实现类
 * </p>
 *
 * @author qwc
 * @since 2025-02-04
 */
@Service
public class SysOrganizationServiceImpl extends ServiceImpl<SysOrganizationMapper, SysOrganization> implements ISysOrganizationService {

    @Override
    public List<OrgTreeDto> tree() {
        List<SysOrganization> sysOrganizations = this.getBaseMapper().selectList(Wrappers.<SysOrganization>lambdaQuery().eq(SysOrganization::getDeleted, Constants.UN_DELETED));
        return OrgTreeDto.buildTree(sysOrganizations);
    }
}
